package com.huxin.servelt.admin;


import com.alibaba.fastjson.JSON;
import com.huxin.pojo.BooksInfo;
import com.huxin.service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 管理员点击通过审核用户
 */
@WebServlet("/admin/agreeUser")
public class AdminAgreeUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String aid = req.getParameter("aid");
        Userservice userservice = new Userservice();
        if (Integer.valueOf(aid)==0){//一键通过
            int i=userservice.AdminAgreeUserAll();
            if (i>0){
                resp.getWriter().write("1");
            }
        }else {
            int i=userservice.AdminAgreeUser(aid);
            if (i==1){
                resp.getWriter().write("1");
            }
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
